package com.fk.loki.circle;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.fk.loki.R;

/**
 * 作用于矩形图片上的白色光带控件
 * @author Hilex
 * @date 2021-3-4
 */
public class RectBeltView extends FrameLayout {

    public RectBeltView(Context context){
        this(context,null);
    }

    public RectBeltView(Context context, AttributeSet attrs){
        this(context,attrs,0);
    }

    public RectBeltView(Context context, AttributeSet attrs, int defStyle){
        super(context,attrs,defStyle);
        TypedArray typedArray=context.obtainStyledAttributes(attrs,R.styleable.RectBeltView,defStyle,0);
        int res=typedArray.getResourceId(R.styleable.RectBeltView_rectBeltRes,R.drawable.constellation);
        int mBeltCycle = typedArray.getInt(R.styleable.RectBeltView_rectBeltCycle, 2000);
        float mBeltWidthPercentage = typedArray.getFloat(R.styleable.CircleBeltView_circleBeltWidthPercentage, 0.24f);
        typedArray.recycle();

        LayoutInflater.from(context).inflate(R.layout.rect_belt,this,true);
        ImageView mImageView = (ImageView) findViewById(R.id.imageView_belt);
        RectBelt mRectBelt = (RectBelt) findViewById(R.id.rectBelt);
        mImageView.setBackgroundResource(res);
        mRectBelt.setBeltCycle(mBeltCycle);
        mRectBelt.setBeltWidthPercentage(mBeltWidthPercentage);
    }


}
